package com.travel.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.travel.base.impl.BaseDaoImpl;
import com.travel.bean.Hotspot;
import com.travel.bean.SpotPicture;
import com.travel.dao.HotSpotDao;
import com.travel.service.HotSpotService;
@Service("hostSpotserviceImpl")
public class HotSpotServiceImpl extends BaseDaoImpl<Hotspot> implements HotSpotService {
	
	@Resource(name="hotSpotDaoImpl")
	private HotSpotDao hotSpotDaoImpl;
	
	/**
	 * 在首页上显示的三个热点推荐
	 */
	@Override
	public List<Map> indexHotSpot() {
		// TODO Auto-generated method stub
		List<Hotspot> hotSpots=hotSpotDaoImpl.getHotSpotByPage(null, 1, 3);
		List<Map> list=new ArrayList();
		for (Hotspot spot : hotSpots) {
			Set<SpotPicture> spotpics=spot.getSpot().getSpotPictures();
			Map map=new HashMap();
			map.put("id", spot.getId());
			map.put("name", spot.getSpot().getName());
			map.put("count", spot.getCount());
			map.put("info", spot.getSpot().getInfo());
			for (SpotPicture spotPicture : spotpics) {
				map.put("picpath", spotPicture.getPath());
				map.put("picname", spotPicture.getName());
			}
			list.add(map);
		}
		return list;
	}

	
}
